﻿using FluentValidation;
using Services.Activity.Domain.ValueObjects;

namespace Services.Activity.WebApi.Request;

public class CreateActivityRequest
{
    public string ActivityName { get; set; }
    public DateTime ActivityStartTime { get; set; }
    public DateTime ActivityCompleteTime { get; set; }
    public ActivityTypes ActivityType { get; set; }
    public string ActivityDescription { get; set; }
    public string ActivityAddress { get; set; }
    public string ActivityAdvertisePhotoBase64 { get; set; }
    
}
public class CreateActivityRequestValidator : AbstractValidator<CreateActivityRequest>
{
    public CreateActivityRequestValidator()
    {
        RuleFor(x => x.ActivityName).NotEmpty().WithMessage("活动名不能为空");
        RuleFor(x => x.ActivityStartTime).Must(x => DateTime.Compare(x, DateTime.Now) > 0).WithMessage("活动开始时间必须晚于当前时间");
        RuleFor(x => x.ActivityCompleteTime).Must((x, c) => DateTime.Compare(x.ActivityCompleteTime, x.ActivityStartTime) > 0).WithMessage("活动开始时间必须早于结束时间");
        RuleFor(x => x.ActivityType).Must(x => (int)x > 0 && (int)x < 6).WithMessage("请选择正确的活动类型");
    }
}
